package com.inxedu.os.edu.service.course.impl;

import com.inxedu.os.edu.dao.SysSubjectMapper;
import com.inxedu.os.edu.pojo.QuerySubject;
import com.inxedu.os.edu.pojo.SysSubject;
import com.inxedu.os.edu.service.course.CourseSubjectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;


/**
 * 课程专业
 */
@Service
public class CourseSubjectServiceimpl implements CourseSubjectService {

    @Autowired
    private SysSubjectMapper sysSubjectMapper;

    //查询所有专业
    @Override
    public List<SysSubject> findCourseSubjectAll() {

        List<SysSubject> list=sysSubjectMapper.selectCourseSubjectAll();

        return list;
    }


    //修改专业
    @Override
    public int updateSubjectNameByid(String subjectName, Integer subjectId) {

        SysSubject subject = new SysSubject();
        subject.setSubjectId(subjectId);
        subject.setSubjectName(subjectName);

        int i = sysSubjectMapper.updateByPrimaryKeySelective(subject);

        return i;
    }


    //删除专业
    @Override
    public int deleteSubjectNameByid(Integer subjectId) {
        int i=sysSubjectMapper.deleteSubjectNameByid(subjectId);

        return i;
    }

    //添加专业
    @Override
    public int addSubject(SysSubject subject) {
        subject.setCreateTime(new Date());
        subject.setStatus(0);
        subject.setSort(0);

        int i = sysSubjectMapper.insert(subject);

        return i;
    }


}
